from django.contrib import admin
from server.models import User, Article, UserLikeArticle, Notification, Comment, UserInfo
# Register your models here.

class UserAdmin(admin.ModelAdmin):
    list_display = ['id', 'username', 'email', 'is_active']

admin.site.register(User, UserAdmin)

class UserInfoAdmin(admin.ModelAdmin):
    list_display = ['user', 'nickname', 'gender', 'avatar', 'follower_list']

    def follower_list(self, obj):
        return [f.id for f in obj.followers.all()]

admin.site.register(UserInfo, UserInfoAdmin)

class ArticleAdmin(admin.ModelAdmin):
    list_display = [f.name for f in Article._meta.fields]+['liked_by']

    def liked_by(self, obj):
        return  obj.liked_by.all()

admin.site.register(Article, ArticleAdmin)


class UserLikeArticleAdmin(admin.ModelAdmin):
    list_display = [f.name for f in UserLikeArticle._meta.fields]

admin.site.register(UserLikeArticle, UserLikeArticleAdmin)

class CommentAdmin(admin.ModelAdmin):
    list_display = [f.name for f in Comment._meta.fields]

admin.site.register(Comment, CommentAdmin)

class NotificationAdmin(admin.ModelAdmin):
    list_display = [f.name for f in Notification._meta.fields]

admin.site.register(Notification, NotificationAdmin)
